# $Id: PKGBUILD 179762 2013-03-09 17:47:45Z andrea $
# Maintainer: Andrea Scarpino <andrea@archlinux.org>

pkgname=phonon
pkgver=4.6.0
pkgrel=8
epoch=1
arch=('i686' 'x86_64')
url='http://phonon.kde.org/'
license=('LGPL')
pkgdesc="The multimedia framework for KDE"
depends=('phonon-backend' 'libpulse' 'libqzeitgeist')
optdepends=('pulseaudio: PulseAudio support')
makedepends=('cmake' 'automoc4' 'pulseaudio')
source=("http://download.kde.org/stable/${pkgname}/${pkgver}/src/${pkgname}-${pkgver}.tar.xz"
        'fix-plugindir-for-qt-app.patch'
        'fix-qmake.patch')
md5sums=('bbe0c1c62ed14c31479c4c1a6cf1e173'
         'e37d67038c2501f25ac7ee7c2de54a9a'
         'c17d8617e9482f02b3e098842946b679')

build() {
  cd ${pkgname}-${pkgver}
  # Upstream fixes
  patch -p1 -i "${srcdir}"/fix-plugindir-for-qt-app.patch
  patch -p1 -i "${srcdir}"/fix-qmake.patch
  cd ../

  mkdir build
  cd build
  cmake ../${pkgname}-${pkgver} \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_SKIP_RPATH=ON \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DPHONON_INSTALL_QT_EXTENSIONS_INTO_SYSTEM_QT=ON \
    -DPHONON_BUILD_DESIGNER_PLUGIN=OFF
  make
}

package(){
  cd build
  make DESTDIR="${pkgdir}" install

  # Install headers into the Qt4 dir
  install -d "${pkgdir}"/usr/include/qt4
  mv "${pkgdir}"/usr/include/{phonon,KDE} "${pkgdir}"/usr/include/qt4/

  sed -i 's#includedir=/usr/include#includedir=/usr/include/qt4#' \
    "${pkgdir}"/usr/lib/pkgconfig/phonon.pc
}
